//
//  HELIdentityDetalVC.m
//  HandheldELearn
//
//  Created by wsj2015 on 2017/1/8.
//  Copyright © 2017年 陈武琦. All rights reserved.
//

#import "HELIdentityDetalVC.h"
#import "HELNormalCell.h"
#import "Tagview.h"
@interface HELIdentityDetalVC ()

@property (nonatomic,  strong) Tagview *tagview;

@property (nonatomic,  strong) HELUser *userInfoModel;



@end

@implementation HELIdentityDetalVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self getPersonInformation];
}


- (void)configUI{
    
    self.dataArray = [@[@[@"单位:"],@[@"科室:",@"职务:",@"职称:",@"能级:",@"编制:"]] copy];
    self.tableView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
    [self.view addSubview:self.tableView];
    [self.tableView registerNib:[UINib nibWithNibName:@"HELNormalCell" bundle:nil] forCellReuseIdentifier:@"HELNormalCell"];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.title = @"身份详情";
    
//    [self.tagview addTags:@[@""]];
    self.tagview;
    
    
}

- (UIView *)tagview{
    if (!_tagview) {
        _tagview = [[Tagview alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 180)];
      
    }
    
    return _tagview;
}

#pragma -mark 获取个人信息
- (void)getPersonInformation{
    /*
     *获取个人信息
     */
//    HELUserInfoM *userInfo = [HELAppManager userInfo];
//    if (!userInfo.userId) {
//        cwqAlertMessage(@"用户id获取失败");
//        return;
//    }
//    weakSelf_define;
//    cwqHud(self.view);
//    
//    NSDictionary *param = @{@"userId":userInfo.userId};
//    [[HELNetworkManager sharedMg] GET:helUserInfoUrl parameters:param success:^(id responseObject) {
//        [hud hideAnimated:YES];
//        if (responseObject[@"exception"]) {
//            cwqHudRequestError(responseObject[@"exception"]);
//        }else {
//            HELUserInfoM *model = [HELUserInfoM mj_objectWithKeyValues:responseObject];
//            weakSelf.userInfoModel = model;
//            [weakSelf updateLocalUserInfo:model];
//
//            [weakSelf.tableView reloadData];
//            
//        }
//        
//        
//    } failure:^(NSString *err) {
//        [hud hideAnimated:YES];
//        cwqHudRequestError(err);
//        
//    }];
}

- (void)updateLocalUserInfo:(HELUser *)newInfo {
    
//    helUserInfo
//    if (newInfo.photo && ![userInfo.photo isEqualToString:newInfo.photo]) {
//        userInfo.photo = newInfo.photo;
//        NSString *baseURL = [[[HELNetworkManager sharedMg] getBaseUrl] stringByAppendingString:@"/upload/userphoto/"];
//        userInfo.photoShowMap = newInfo.photoShowMap;
//        userInfo.photoShowMap.mini = [baseURL stringByAppendingString:newInfo.photo];
//    }
//    if (newInfo.email && ![userInfo.email isEqualToString:newInfo.email]) {
//        
//        userInfo.email = newInfo.email;
//    }
//    
//    NSMutableDictionary *dict = [[userInfo mj_keyValues] mutableCopy];
//    [HELAppManager saveUseInfo:dict];
    
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return  self.dataArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.dataArray[section] count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    HELNormalCell *cell =[tableView dequeueReusableCellWithIdentifier:@"HELNormalCell"];
    
    UIView *view = [UIView new];
    view.alpha = .7;
    view.frame = cell.bounds;
    view.backgroundColor = kMainColor;
    cell.selectedBackgroundView =view;
    NSString *title =self.dataArray[indexPath.section][indexPath.row];
    cell.mainTitleL.text = title;
    
   
    
    cell.subTitleL.hidden = NO;
    cell.rightIndcator.hidden = YES;
    if (!self.userInfoModel) {
        cell.subTitleL.text =@"";
    }else{
        
        if (indexPath.section == 0) {
//             cell.subTitleL.text = [NSString stringWithFormat:@"%@",self.userInfoModel.dataDictValue];
        }
        
        if (indexPath.section == 1) {
            switch (indexPath.row) {
                case 0:
                  
//                    cell.subTitleL.text = self.userInfoModel.departmentName;
                    break;
                case 1:
                   
//                    cell.subTitleL.text= self.userInfoModel.appointmentDutyName;
                    break;
                case 2:
//                    cell.subTitleL.text=self.userInfoModel.professionalDutyName;
                    break;
                case 3:
//                    cell.subTitleL.text=self.userInfoModel.nurseLevel;
                    break;
                case 4:
//                    cell.subTitleL.text = self.userInfoModel.employeeCategoryDis;
                    break;
                    
                default:
                    break;
            }
        }
        
    
    }
    
  
    
    
    return cell;
    
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    
}
- (UIView*)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    if (section == 1) {
        return  self.tagview;
    }
    UIView *view =[UIView new];
    view.frame =CGRectMake(0, 0, kScreenWidth, 10);
    view.backgroundColor =[UIColor clearColor];
    return view;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 1) {
        return 180;
    }
    return 12;
}
@end
